package com.yanqu.road.server.cmd.activity.langyabang.fromCross;

import com.yanqu.road.entity.union.UnionMember;
import com.yanqu.road.entity.union.cross.CrossUnionInfo;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.LangYaBangProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.manger.union.CrossUnionMgr;
import com.yanqu.road.server.manger.union.UnionMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

import java.util.Map;
@Deprecated
@Cmd(code = GameProtocol.S_LANG_YA_BANG_CROSS_RED_DOT_SYNC_TO_GAME,desc = "红点跨服同步到游戏服")
public class LangYaBangRedDotFromCross extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        LangYaBangProto.LangYaBangRedDotSyncToServerReqMsg reqMsg = LangYaBangProto.LangYaBangRedDotSyncToServerReqMsg.parseFrom(packet.getBytes());
        String unionUid = reqMsg.getUnionUid();
        Map<Long, UnionMember> unionMemberMap = UnionMgr.getUnionMemberMap(unionUid);
        if (unionMemberMap != null){
            for (long userId:unionMemberMap.keySet()){
                GamePlayer onlinePlayer = GamePlayerMgr.getOnlinePlayer(userId);
                if (onlinePlayer != null){
                    player.sendPacket(ClientProtocol.U_LANG_YA_BANG_RED_DOT_SYNC,reqMsg.getRedDot().toBuilder());
                }
            }
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
